package com.totoro.service.impl;

import com.totoro.mapper.ShopMapper;
import com.totoro.pojo.*;
import com.totoro.service.ShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * @author TOTORO
 * @date 2021/7/12 9:39
 */
@Service
public class ShopServiceImpl implements ShopService {

    @Autowired
    ShopMapper shopMapper;

    @Override
    public Integer findShopIdByPid(int pid) {
        return shopMapper.findShopIdByPid(pid);
    }

    @Override
    public Shop findShopBySlid(int slid) {
        return shopMapper.findShopBySlid(slid);
    }

    @Override
    public Shop findShopBySid(int sid) {
        return shopMapper.findShopBySid(sid);
    }

    @Override
    public Integer[] randomFindFiveShopId() {
        return shopMapper.randomFindFiveShopId();
    }

    @Override
    public List<Product> findShopMaxDealProduct() {
        Integer[] integers = shopMapper.randomFindFiveShopId();
        return shopMapper.findShopMaxDealProduct(integers);
    }

    @Override
    public Shop findAllProduct(int sid, int limit1, int limit2) {
        return shopMapper.findAllProduct(sid, limit1, limit2);
    }

    @Override
    public List<Product> findTermDescProduct(int sid, String descSql) {
        return shopMapper.findTermDescProduct(sid, descSql);
    }

    @Override
    public List<Product> findAllShopCategoryAndProduct(int scid, String keyWord, String descSql, double lowPrice, double highPrice, int curr) {
        return shopMapper.findAllShopCategoryAndProduct(scid, keyWord, descSql, lowPrice, highPrice, curr);
    }

    @Override
    public List<Product> keywordSearchShopProduct(int sid, String keyWord, String descSql, double lowPrice, double highPrice, int curr) {
        return shopMapper.keywordSearchShopProduct(sid, keyWord, descSql, lowPrice, highPrice, curr);
    }

    @Override
    public List<ShopCategory> findAllShopCategory(int sid) {
        return shopMapper.findAllShopCategory(sid);
    }

    @Override
    public Integer checkShopCategoryName(ShopCategory shopCategory) {
        return shopMapper.checkShopCategoryName(shopCategory);
    }

    @Override
    public Integer addShopCategory(String scName, int sid) {
        return shopMapper.addShopCategory(scName, sid);
    }

    @Override
    public Integer addProductGoToCategory(int scid, int pid) {
        return shopMapper.addProductGoToCategory(scid, pid);
    }

    @Override
    public Integer deleteShopCategory(int scid) {
        return shopMapper.deleteShopCategory(scid);
    }

    @Override
    public Integer updateCategoryProductEmpty(int scid) {
        return shopMapper.updateCategoryProductEmpty(scid);
    }

    @Override
    public Integer updateShopStar(ProductComment productComment) {
        return shopMapper.updateShopStar(productComment);
    }

    @Override
    public Shop findOtherMaxScore(int slid) {
        return shopMapper.findOtherMaxScore(slid);
    }

    @Override
    public List<ShopSwitchImage> findShopSwitchImage(int sid, String ImagePath) {
        return shopMapper.findShopSwitchImage(sid, ImagePath);
    }

    @Override
    public Integer addShopAccess(int sid) {
        return shopMapper.addShopAccess(sid);
    }

    @Override
    public List<DayCount> findShopDayAccessCount(int sid) {
        return shopMapper.findShopDayAccessCount(sid);
    }

    @Override
    public Integer addShopPay(int sid, double payMoney) {
        return shopMapper.addShopPay(sid, payMoney);
    }

    @Override
    public List<DayCount> findShopDayPayMoney(int sid) {
        return shopMapper.findShopDayPayMoney(sid);
    }

    @Override
    public List<DayCount> findShopDayPayChildOrder(int sid) {
        return shopMapper.findShopDayPayChildOrder(sid);
    }

    @Override
    public List<DayCount> findShopDayPayUserCount(int sid) {
        return shopMapper.findShopDayPayUserCount(sid);
    }

    @Override
    public Integer collectShop(int uid, int sid) {
        return shopMapper.collectShop(uid, sid);
    }

    @Override
    public CollectShop checkUserCollectShop(int uid, int sid) {
        return shopMapper.checkUserCollectShop(uid, sid);
    }

    @Override
    public Map<CollectShop, List<Product>> findCollectShop(int uid, String keyword) {
        Map<CollectShop, List<Product>> shopListMap = new LinkedHashMap<>();
        List<CollectShop> collectShop = shopMapper.findAllUserCollectShop(uid, keyword);
        for (CollectShop shop : collectShop) {
            System.out.println(shop);
            List<Product> products = shopMapper.findCollectShop(shop.getShop().getId());
            shopListMap.put(shop, products);
        }
        return shopListMap;
    }

    @Override
    public Integer cancelCollectShop(int uid, int sid) {
        return shopMapper.cancelCollectShop(uid,sid);
    }

    @Override
    public Integer updateShopCollectCount(int type, int sid) {
        return shopMapper.updateShopCollectCount(type, sid);
    }

    @Override
    public Integer batchReduceShopCollectCount(Integer[] collectIds) {
        return shopMapper.batchReduceShopCollectCount(collectIds);
    }

    @Override
    public Integer batchDeleteCollectShop(Integer[] collectIds) {
        return shopMapper.batchDeleteCollectShop(collectIds);
    }
}
